package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.*;

public class BankApplication {

    public static ClientRegistrationListener listeners[] = new ClientRegistrationListener[3];

    private static Bank bank = new Bank(listeners);

    public static void modifyBank() {

        bank.clients[0].checkingAccount.deposit(16);
        bank.clients[0].savingAccount.withdraw(455);

    }


    public static void printBalance() {

        int length = bank.clients.length;
        for (int i = 0; i < length; i++) {
            if (bank.clients[i] == null) {
                break;
            }

            if (bank.clients[i].savingAccount != null) {
                System.out.printf("Client #%d || FIO:  %s || Balance: %.2f\n", i + 1, bank.clients[i].getClientSalutation(), bank.clients[i].savingAccount.getBalance());
            }
            if (bank.clients[i].checkingAccount != null) {
                System.out.printf("Client #%d || FIO:  %s || Balance: %.2f\n", i + 1, bank.clients[i].getClientSalutation(), bank.clients[i].checkingAccount.getBalance());
            }

        }
    }

    public static void main(String[] args) {

        listeners[0] = new Bank.PrintClientListener();
        listeners[1] = new Bank.EmailNotificationListener();
        listeners[2] = new Bank.DebugListener();


        BankService.addClient(bank, new Client("Kolobkova Ira", Gender.Female));
        bank.clients[0].savingAccount = new SavingAccount(123456.024);
        bank.clients[0].checkingAccount = new CheckingAccount(1.5, 2);


        BankService.addClient(bank, new Client("Toporov Ivan", Gender.Male));
        bank.clients[1].savingAccount = new SavingAccount(456.024);


        BankService.printMaximumAmountToWithdraw(bank);
        printBalance();
        modifyBank();
        System.out.printf("------------------------------------------Modify-------------------------------------\n");

        printBalance();
    }

}